package com.core.sgip.common;

import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

import com.core.sgip.interf.SGIPmessageHandler;

public class SGIPproperties {
	/**
	 * 本机服务网关ip
	 */
	public static String LOCALHOST_REQUEST_SERVER_IP;
	
	/**
	 * 本机服务网关port
	 */
	public static int LOCALHOST_REQUEST_SERVER_PORT;
	
	public static String COMPANY_CODE;

	public static String AREA_CODE;

	public static String SP_NUMBER;

	public static int SGIP_SUBMIT_MAX_USER_NUMBER;


	private static String SGIP_MESSAGE_HANDLE_CLASS;

	public static String DEFAULT_SERVICE_TYPE;

	public static SGIPmessageHandler SGIP_MSG_HANDLER = null;

	public static String IS_NIO;

	public static String HTTPURL;
	public static String HTTPAPPKEY;
	public static String HTTPSECRETKEY;

	static {
		ResourceBundle props = PropertyResourceBundle.getBundle("sgip");
		// FLOW_HOST = rs.getString("traffic.host");
		/**
		 * 广西联通sp接入号
		 */
		SP_NUMBER = props.getString("client.SPNumber");
		AREA_CODE = props.getString("client.login.areaCode");
		COMPANY_CODE = props.getString("client.login.companyCode");
		SGIP_SUBMIT_MAX_USER_NUMBER = Integer.valueOf(props.getString("sgip.submit.usernumber.max"));

		@SuppressWarnings("unused")
		String timeout = props.getString("sgip.receive.response.timeout");
		LOCALHOST_REQUEST_SERVER_IP = props.getString("localhost.request.sgip.service.ip");
		LOCALHOST_REQUEST_SERVER_PORT = Integer.valueOf(props.getString("localhost.request.sgip.service.port"));

		DEFAULT_SERVICE_TYPE = props.getString("sgip.submit.service.type");

		IS_NIO = props.getString("sgip.client.nio");

		SGIP_MESSAGE_HANDLE_CLASS = props.getString("sgip.message.handle.class");

		HTTPURL = props.getString("sgip.service.doHandle.url");
		HTTPAPPKEY = props.getString("sgip.service.doHandle.appkey");
		HTTPSECRETKEY = props.getString("sgip.service.doHandle.secretKey");

		@SuppressWarnings("rawtypes")
		Class clazz = null;
		try {
			clazz = Class.forName(SGIP_MESSAGE_HANDLE_CLASS);
			SGIP_MSG_HANDLER = (SGIPmessageHandler) clazz.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	// @SuppressWarnings("unused")
	// private static void initInstanceOfHandler(String messageHandlerClass) {
	// try {
	// @SuppressWarnings("rawtypes")
	// Class clazz = Class.forName(SGIP_MESSAGE_HANDLE_CLASS);
	// SGIP_MSG_HANDLER = (SGIPmessageHandler) clazz.newInstance();
	// } catch (ClassNotFoundException e) {
	// e.printStackTrace();
	// } catch (InstantiationException e) {
	// e.printStackTrace();
	// } catch (IllegalAccessException e) {
	// e.printStackTrace();
	// }
	// }

}
